package org.frv.wispr.web.account;

import org.apache.wicket.security.hive.authorization.Principal;
import org.apache.wicket.security.hive.authentication.Subject;

/**
 * Created by IntelliJ IDEA.
 * User: frank
 * Date: Jan 8, 2008
 * Time: 7:57:11 PM
 * To change this template use File | Settings | File Templates.
 */
public class UserPrincipal implements Principal {
    private String name;

    public UserPrincipal(String name) {
        super();
        this.name = name;
        if (name == null) {
            throw new IllegalArgumentException("Name must be specified");
        }
    }

    public String getName() {
       return name;
    }

    public boolean implies(Subject subject) {
        return false;
    }

    public String toString() {
        return getClass().getName() + ": " + getName();
    }

    public int hashCode() {
		final int PRIME = 31;
		int result = 1;
		result = PRIME * result + ((name == null) ? 0 : name.hashCode());
		result = PRIME * result + getClass().hashCode();
		return result;
	}

    public boolean equals(Object obj)
    {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        final UserPrincipal other = (UserPrincipal) obj;
        if (name == null) {
            if (other.name != null) {
                return false;
            }
        }
        else if (!name.equals(other.name)) {
            return false;
        }
        return true;
    }
}